<?php
/**
 * Created by PhpStorm.
 * User: Dick
 * Date: 2016/3/28
 * Time: 15:15
 */

namespace Method;


class JSON
{
    public static function json($data = array(), $code = 200, $extras = '')
    {
        header('Content-type: application/json');
        if ($extras == '') {
            echo json_encode(array(
                'code' => $code,
                'data' => $data,
            ));
        } else {
            echo json_encode(array_merge(array(
                'code' => $code,
                'data' => $data,
            ), $extras));
        }
        exit();
    }
}